/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fr.monVehicule.presentation.ajouter.action;

import com.opensymphony.xwork2.ActionSupport;
import fr.monVehicule.coordination.ajouter.vehicule.AjouterVehiculeProcessus;
import fr.monVehicule.presentation.ajouter.form.VehiculeForm;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
import org.apache.struts2.interceptor.SessionAware;

/**
 *
 * @author David
 */
public class AjouterVehiculeAction extends ActionSupport implements SessionAware{
    
    VehiculeForm vehicule ;
    Map<String, Object> m;
    String date;

    public void setDate(String date) {
        this.date = date;
    }
    public VehiculeForm getVehicule() {
        return vehicule;
    }

    public void setVehicule(VehiculeForm vehicule) {
        this.vehicule = vehicule;
    }
    
    @Override
    public String execute() throws Exception {
        SimpleDateFormat parseFormatter = new SimpleDateFormat("yyyy-MM-dd");
        Date d = parseFormatter.parse(date);
        vehicule.setMiseEnCirculation(d);
        AjouterVehiculeProcessus process = new AjouterVehiculeProcessus(vehicule);
        process.execute();
        
        //m.put(SessionUtil.VEHICULE_SESSION, vehicule);
        return SUCCESS;
    }

    @Override
    public void setSession(Map<String, Object> map) {
        this.m = map;
    }
}
